package kr.hkit.androidcomplete02.actionbar;

import kr.hkit.androidcomplete02.MainActivity;
import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

public class AppLogoIcon extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		TextView text = new TextView(this);
		text.setText("타이틀 바의 로고 아이콘을 누르시오");
		setContentView(text);
		getActionBar().setHomeButtonEnabled(true);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.actionbarmenu, menu);
		return super.onCreateOptionsMenu(menu);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		 super.onOptionsItemSelected(item);
		 
		 switch (item.getItemId()) {
		 case R.id.one:
			 Toast.makeText(this,"첫번째 액션 항목 선택",Toast.LENGTH_SHORT).show();
			 return true;
		 case android.R.id.home:
			 Toast.makeText(this,"로고 아이콘 선택",Toast.LENGTH_SHORT).show();
			 Intent intent = new Intent(this, MainActivity.class);
			 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			 startActivity(intent);
			 return true;
		 }
		 return false;
	}
}
